<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="http://medoo.in/css/core.css"/>
<link rel="shortcut icon" href="http://medoo.in/favicon.png" />
<meta property="og:title" content="Medoo - The lightest PHP database framework to accelerate development"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="http://medoo.in"/>
<meta property="og:image" content="http://medoo.in/images/medoo-logo-128.png"/>
<meta property="og:site_name" content="Medoo"/>
<meta property="fb:admins" content="100001162628592" />
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObjects']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-15301273-5', 'medoo.in');ga('send', 'pageview');</script><title>Guidebook - Medoo</title>
<meta name="keywords" content="Medoo,Medoo Guidebook" />
<meta name="description" content="Medoo Guidebook" />
<script type="text/javascript" src="../js/qatrix-1.1.js"></script>
<script type="text/javascript" src="../js/prettify.js"></script>
<script type="text/javascript">
$ready(function ()
{
	prettyPrint();
	$className.add($('api_list_new'), 'on');
});
</script>
</head>
<body>
<header>
<div id="header_body" class="clearfix">
<a href="http://medoo.in"><img width="297" height="58" id="head_logo" src="http://medoo.in/images/medoo-logo.png" /></a>
<nav>
	<ul class="clearfix">
		<li><a href="http://medoo.in">Home</a></li>
		<li><a href="http://medoo.in/api/new">Get Started</a></li>
		<li><a href="http://medoo.in/doc">Documentation</a></li>
		<li><a href="http://medoo.in/about">About</a></li>
	</ul>
</nav>
</div>
</header><div id="doc_container" class="clearfix">
	<div id="api_list_wrap">
<h4>Get Started</h4 >
<ul class="api_list">
<li id="api_list_new"><a href="http://medoo.in/api/new">new medoo()</a></li>
</ul>

<h4>Where Syntax</h4 >
<ul class="api_list">
<li id="api_list_where"><a href="http://medoo.in/api/where">where</a></li>
</ul>

<h4>Query</h4>
<ul class="api_list">
<li id="api_list_select"><a href="http://medoo.in/api/select">select</a></li>
<li id="api_list_insert"><a href="http://medoo.in/api/insert">insert</a></li>
<li id="api_list_update"><a href="http://medoo.in/api/update">update</a></li>
<li id="api_list_delete"><a href="http://medoo.in/api/delete">delete</a></li>
<li id="api_list_replace"><a href="http://medoo.in/api/replace">replace</a></li>
<li id="api_list_get"><a href="http://medoo.in/api/get">get</a></li>
<li id="api_list_has"><a href="http://medoo.in/api/has">has</a></li>
<li id="api_list_count"><a href="http://medoo.in/api/count">count</a></li>
<li id="api_list_max"><a href="http://medoo.in/api/max">max</a></li>
<li id="api_list_min"><a href="http://medoo.in/api/min">min</a></li>
<li id="api_list_avg"><a href="http://medoo.in/api/avg">avg</a></li>
<li id="api_list_sum"><a href="http://medoo.in/api/sum">sum</a></li>
</ul>

<h4>Transaction</h4 >
<ul class="api_list">
<li id="api_list_action"><a href="http://medoo.in/api/action">action</a></li>
</ul>

<h4>Advanced</h4>
<ul class="api_list">
<li id="api_list_query"><a href="http://medoo.in/api/query">query</a></li>
<li id="api_list_quote"><a href="http://medoo.in/api/quote">quote</a></li>
</ul>

<h4>PDO object</h4>
<ul class="api_list">
<li id="api_list_pdo"><a href="http://medoo.in/api/pdo">pdo</a></li>
</ul>

<h4>Debug</h4>
<ul class="api_list">
<li id="api_list_debug"><a href="http://medoo.in/api/debug">debug</a></li>
<li id="api_list_error"><a href="http://medoo.in/api/error">error</a></li>
<li id="api_list_log"><a href="http://medoo.in/api/log">log</a></li>
<li id="api_list_last_query"><a href="http://medoo.in/api/last_query">last_query</a></li>
</ul>

<h4>Information</h4>
<ul class="api_list">
<li id="api_list_info"><a href="http://medoo.in/api/info">info</a></li>
</ul>
</div>
	<div id="main_body">
		<div id="doc_version">version: 1.1.3</div>
<h3>Get Started</h3>
<p class="intro">Using Medoo is extremely easy!</p>

<h4>Requirement</h4>
<ul id="requirement_list">
	<li>PHP 5.1+, greatly recommend for PHP 5.4+ with PDO support.</li>
	<li>Installed database like MySQL, MSSQL, SQLite or more.</li>
	<li>Make sure php_pdo_xxx extension is enabled and installed.</li>
	<li>A little bit SQL knowledge.</li>
</ul>

<h4>Tips</h4>
<p class="intro">On PHP 5.4+, you can use <b>[]</b> as short array syntax. All Medoo example code are using [] instead of array().</p>
<pre class="prettyprint linenums">
// On PHP 5.1
$data = array(&quot;foo&quot;, &quot;bar&quot;);

// On PHP 5.4+
$data = [&quot;foo&quot;, &quot;bar&quot;];
</pre>

<h4>php_pdo extension list</h4>
<ul id="requirement_list">
	<li>MySQL, MariaDB -> php_pdo_mysql</li>
	<li>MSSQL (Windows) -> php_pdo_sqlsrv</li>
	<li>MSSQL (Linux/UNIX) -> php_pdo_dblib</li>
	<li>Oracle -> php_pdo_oci</li>
	<li>SQLite -> php_pdo_sqlite</li>
	<li>PostgreSQL -> php_pdo_pgsql</li>
	<li>Sybase -> php_pdo_dblib</li>
</ul>

<h4>PHP PDO driver installation</h4>
<p class="intro">Medoo is requiring PHP with PDO supported. If you didn't install before, follow this step.</p>
<pre class="prettyprint linenums">
// Open php.ini and remove the &#039;;&#039; for the database extension you want to install.

// From
;extension=php_pdo_mysql.dll

// To
extension=php_pdo_mysql.dll

// Save it, and restart PHP or Apache server.

// If PDO is installed successfully, you can find it on phpinfo().
</pre>

<p class="intro">Or install via terminal. The PDO_XXX extension will be enabled and configured automatically.</p>
<code class="console-code">
$ sudo apt-get install php5-mysql
</code>

<h4>Composer Installation</h4>
<p class="intro">If you know about composer, it is easy to install and manage the version dependence. Just use this command to add Medoo to composer.json. Or you can edit it depend on your requirement.</p>

<code class="console-code">
$ composer require catfan/Medoo
</code>

<p class="intro">And update the composer</p>

<code class="console-code">
$ composer update
</code>

<h4>Download Installation</h4>
<p class="intro">The most simple way. Just download medoo.php and put it into the right directory and then require, and now you are ready!</p>
<pre class="prettyprint linenums">
require  &#039;medoo.php&#039;;
</pre>

<h4>Configuration</h4>
<p class="intro">There are three ways to configure medoo and start a database connection.</p>
<pre class="prettyprint linenums">
// If you installed via composer, just use this code to requrie autoloader on the top of your projects.
require &#039;vendor/autoload.php&#039;;

// Or if you just download the medoo.php into directory, require it with the correct path.
require  &#039;medoo.php&#039;;

$database = new medoo([
	// required
	&#039;database_type&#039; =&gt; &#039;mysql&#039;,
	&#039;database_name&#039; =&gt; &#039;name&#039;,
	&#039;server&#039; =&gt; &#039;localhost&#039;,
	&#039;username&#039; =&gt; &#039;your_username&#039;,
	&#039;password&#039; =&gt; &#039;your_password&#039;,
	&#039;charset&#039; =&gt; &#039;utf8&#039;,

	// [optional]
	&#039;port&#039; =&gt; 3306,

	// [optional] Table prefix
	&#039;prefix&#039; =&gt; &#039;PREFIX_&#039;,

	// [optional] driver_option for connection, read more from http://www.php.net/manual/en/pdo.setattribute.php
	&#039;option&#039; =&gt; [
		PDO::ATTR_CASE =&gt; PDO::CASE_NATURAL
	]
]);

$database-&gt;insert(&quot;account&quot;, [
	&quot;user_name&quot; =&gt; &quot;foo&quot;,
	&quot;email&quot; =&gt; &quot;foo@bar.com&quot;
]);
</pre>

<h4>For MSSQL</h4>
<div class="note">If you want to use MSSQL with Medoo under PHP platform, you need to install <b>pdo_sqlsrv</b> PHP extension for Windows or <b>pdo_dblib</b> for Linux/UNIX. pdo_mssql extension is deprecated and will be removed from PHP.</div>

<h4>For SQLite</h4>
<pre class="prettyprint linenums">
$database = new medoo([
	&#039;database_type&#039; =&gt; &#039;sqlite&#039;,
	&#039;database_file&#039; =&gt; &#039;my/database/path/database.db&#039;
]);

$database-&gt;insert(&quot;account&quot;, [
	&quot;user_name&quot; =&gt; &quot;foo&quot;,
	&quot;email&quot; =&gt; &quot;foo@bar.com&quot;
]);
</pre>

		</div>
	</div>

<footer>
<div id="footer_body" class="clearfix">
<a id="github_link" href="https://github.com/catfan/Medoo">
<div id="github_text">Fork me on GitHub</div>
</a><p id="footer_text">The Medoo project, All Rights Reserved, 2017.</p>
</div>
</footer></body>
</html>